home *** CD-ROM | disk | FTP | other *** search
/ Revista do CD-ROM 118 / cd-rom 118.iso / aplic / open / openofficeorg4.cab / __init__6.py < prev    next >
Encoding:
Python Source  |  2005-02-15  |  1.8 KB  |  73 lines

  1. # Copyright (C) 2001-2004 Python Software Foundation
  2. # Author: barry@python.org (Barry Warsaw)
  3.  
  4. """A package for parsing, handling, and generating email messages.
  5. """
  6.  
  7. __version__ = '2.5.5'
  8.  
  9. __all__ = [
  10.     'base64MIME',
  11.     'Charset',
  12.     'Encoders',
  13.     'Errors',
  14.     'Generator',
  15.     'Header',
  16.     'Iterators',
  17.     'Message',
  18.     'MIMEAudio',
  19.     'MIMEBase',
  20.     'MIMEImage',
  21.     'MIMEMessage',
  22.     'MIMEMultipart',
  23.     'MIMENonMultipart',
  24.     'MIMEText',
  25.     'Parser',
  26.     'quopriMIME',
  27.     'Utils',
  28.     'message_from_string',
  29.     'message_from_file',
  30.     ]
  31.  
  32. try:
  33.     True, False
  34. except NameError:
  35.     True = 1
  36.     False = 0
  37.  
  38.  
  39.  
  40. # Some convenience routines.  Don't import Parser and Message as side-effects
  41. # of importing email since those cascadingly import most of the rest of the
  42. # email package.
  43. def message_from_string(s, _class=None, strict=False):
  44.     """Parse a string into a Message object model.
  45.  
  46.     Optional _class and strict are passed to the Parser constructor.
  47.     """
  48.     from email.Parser import Parser
  49.     if _class is None:
  50.         from email.Message import Message
  51.         _class = Message
  52.     return Parser(_class, strict=strict).parsestr(s)
  53.  
  54. def message_from_file(fp, _class=None, strict=False):
  55.     """Read a file and parse its contents into a Message object model.
  56.  
  57.     Optional _class and strict are passed to the Parser constructor.
  58.     """
  59.     from email.Parser import Parser
  60.     if _class is None:
  61.         from email.Message import Message
  62.         _class = Message
  63.     return Parser(_class, strict=strict).parse(fp)
  64.  
  65.  
  66.  
  67. # Patch encodings.aliases to recognize 'ansi_x3.4_1968' which isn't a standard
  68. # alias in Python 2.1.3, but is used by the email package test suite.
  69. from encodings.aliases import aliases # The aliases dictionary
  70. if not aliases.has_key('ansi_x3.4_1968'):
  71.     aliases['ansi_x3.4_1968'] = 'ascii'
  72. del aliases # Not needed any more
  73.